package ojchannel

import "sync"

type XStatus struct {
	Code int
	Msg  interface{}
}
type OJChannelX struct {
	C    chan XStatus
	once sync.Once
}

func NewXChannel() *OJChannelX {
	return &OJChannelX{C: make(chan XStatus)}
}

func (this *OJChannelX) SafeClose() {
	this.once.Do(func() {
		close(this.C)
	})
}

func Status(status int, msg interface{}) XStatus {
	var x XStatus
	x.Msg = msg
	x.Code = status
	return x
}
